package com.craftcomputing.client.Entry;

import com.craftcomputing.client.Entry.PhotoWidget.*;
import com.craftcomputing.client.SearchResult.Label.*;
import com.craftcomputing.client.Listeners.EntryPanelListeners;
import com.craftcomputing.client.Listeners.SearchResultLabelListeners.ImageLoadListener;
import com.craftcomputing.client.Listeners.SearchResultListeners.*;
import com.craftcomputing.client.SearchResult.WorkshopSearchResult;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.*;

public class IntroEntryPanel extends Composite {

	public IntroEntryPanel() {
		VerticalPanel panel = new VerticalPanel();
		initWidget(panel);
		panel.setStyleName("introEntryPanel");
		panel.setWidth("800px");

		final VerticalPanel verticalPanel_4 = new VerticalPanel();
		panel.add(verticalPanel_4);
		verticalPanel_4.setWidth("100%");	

		final VerticalPanel linkedWorkshopsPanel = new VerticalPanel();
		panel.add(linkedWorkshopsPanel);
		linkedWorkshopsPanel.setStyleName("gwt-paddedBottom");
		linkedWorkshopsPanel.setWidth("100%");
		linkedWorkshopsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

		String searchText = "/python/workshop?workshopId=";

		final HorizontalPanel horizontalPanel = new HorizontalPanel();
		linkedWorkshopsPanel.add(horizontalPanel);
		horizontalPanel.setSize("100%", "100%");
		horizontalPanel.setSpacing(4);

		final Label workshopsUsedInLabel = new Label("Featured Workshops");
		horizontalPanel.add(workshopsUsedInLabel);
		horizontalPanel.setStyleName("gwt-SingleEntryTab");
		workshopsUsedInLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

		final VerticalPanel workshopsPanel = new VerticalPanel();
		linkedWorkshopsPanel.add(workshopsPanel);
		workshopsPanel.setSize("100%", "100%");
		workshopsPanel.setStyleName("gwt-TabPanel-SingleResult");
		workshopSearchResult.clearResultPanel();
		workshopsPanel.add(workshopSearchResult);
		workshopSearchResult.setSize("796px", "100%");
		HTTPRequest.asyncGet(searchText + "1", new JSONLinkedEntryLabelResponseTextHandler(workshopSearchResult));
		HTTPRequest.asyncGet(searchText + "2", new JSONLinkedEntryLabelResponseTextHandler(workshopSearchResult));
		HTTPRequest.asyncGet(searchText + "3", new JSONLinkedEntryLabelResponseTextHandler(workshopSearchResult));
		
		workshopSearchResult.setStyleName("gwt-TabBar .gwt-Result");

		verticalPanel_4.add(horizontalPanel_4);
		horizontalPanel_4.setWidth("100%");
		horizontalPanel_4.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

		horizontalPanel_4.add(photo);
		horizontalPanel_4.setCellHorizontalAlignment(photo, HasHorizontalAlignment.ALIGN_LEFT);

		horizontalPanel_4.add(richTextArea);
		horizontalPanel_4.setCellWidth(richTextArea, "100%");
		richTextArea.setWidth("455px");
		richTextArea.setStyleName("gwt-RichTextArea");
		horizontalPanel_4.setCellHorizontalAlignment(richTextArea, HasHorizontalAlignment.ALIGN_LEFT);

	}
	public void update(JSONValue json){}
	//private Image photo  = new Image("mainimages/01_11a.jpg");	
	private PhotoWidget photo  = new PhotoWidget("mainimages/02_03a.jpg");	
	private HTML richTextArea = new HTML("" +
			"The availability of easy-to-use programmable microprocessors has opened new doors for children, " +
			"teens and adults to create with digital technologies. Many schools, museums and after school centers " +
			"have invested in this specialized hardware, and educators are developing activities that inspire " +
			"broader audiences to use these technologies.<br><br>" +
			"Craft Computing hopes to inspire educators of think of programmable technology as a creative tool. " +
			"This site explores new ways of sharing art/technology workshop ideas with other educational practitioners. " +
			"In the future, we hope to add even more features and resources to craftcomputing.cc.<br><br>" +
			"Thanks for viewing, and have fun!" );
	private WorkshopSearchResult workshopSearchResult = new WorkshopSearchResult(false);
	private HorizontalPanel horizontalPanel_4 = new HorizontalPanel();
}
